#include "StdAfx.h"
#include "popupmenu.h"

PopupMenu::PopupMenu( QWidget * parent )
:   QMenu( parent )
{
}

PopupMenu::~PopupMenu()
{
}

void PopupMenu::addItem( const QString & text, const QVariant & varData, const QString & iconStr )
{
    QAction * action = new QAction( QIcon( QString( ":/lcc/img/%1" ).arg( iconStr ) ) , text, this );
    addItem( action, varData );
}

void PopupMenu::addItem( const QString & text, const QVariant & varData )
{
    QAction * action = new QAction( text, this );
    addItem( action, varData );
}

QVariant PopupMenu::execAndSelectData( const QPoint & pos )
{
    QAction * action = exec( pos );
    if (action == NULL)
        return QVariant();

    return action->data();
}

void PopupMenu::addItem( QAction * action, const QVariant & varData )
{
    action->setData( varData );
    addAction( action );
}
